﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame7
{
    class Camera2D
    {
        Vector2 posicao = Vector2.Zero;

        private float WidthScreen;
        private float HeightScreen;

        public Camera2D(GraphicsDeviceManager graphics, Vector2 poisicaoInicial)
        {
            this.WidthScreen = graphics.PreferredBackBufferWidth;
            this.HeightScreen = graphics.PreferredBackBufferHeight;

            this.posicao = poisicaoInicial;
        }

        public void Update(Vector2 TargetPosition)
        {
            this.posicao.X = TargetPosition.X - (WidthScreen * 0.5f);
            this.posicao.Y = TargetPosition.Y - (HeightScreen * 0.5f);
        }

        public Vector2 Transform(Vector2 toTransform)
        {
            return new Vector2(toTransform.X - posicao.X, toTransform.Y - posicao.Y);
        }
    }
}
